package com.test.service;

import com.spring.Autowired;
import com.spring.BeanNameAware;
import com.spring.Component;
import com.spring.InitializingBean;

/**
 * @author 颜真明
 * @date 2023/4/28  14:10
 */
@Component("userService")
public class UserServiceImpl implements UserService, BeanNameAware, InitializingBean {

    @Autowired
    private OrderService orderService;

    // 获取当前bean的name，即userService，需要实现BeanNameAware接口
    private String beanName;

    // 验证后置处理器
    private String BeanPostProcessorTest;

    public void setBeanPostProcessorTest(String beanPostProcessorTest) {
        BeanPostProcessorTest = beanPostProcessorTest;
    }

    @Override
    public void setBeanName(String name) {
        this.beanName = name;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        // 用于用户自定义扩展
        System.out.println("InitializingBean");
    }

    @Override
    public void test() {
        System.out.println(orderService);
        System.out.println(beanName);
        System.out.println(BeanPostProcessorTest);
    }


}
